<template>
	<view>
		<view>登录</view>
		<input type="text" v-model="loginData.username">
		<input type="password" v-model="loginData.password">
		<button @click="login">登录</button>
		<view>注册</view>
		<input v-model="registerData.username" type="text">
		<input v-model="registerData.password" type="password">
		<button @click="register">注册</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loginData:{
					username:'',
					password:''
				},
				registerData:{
					username:'',
					password:''
				}
			}
		},
		methods: {
			register(){
				uni.request({
					url:'/api/register',
					method:'post',
					data:this.registerData,
					success:function(res){
						console.log(res);
					}
				})
			},
			login(){
				uni.request({
					url:'/api/login',
					method:"post",
					data:this.loginData,
					success:function(res){
						console.log(res)
					}
				})
			}
		}
	}
</script>

<style>
input{
	border: 1px solid #eee;
	height: 60rpx;
	margin: 4rpx 0;
}
</style>
